
package com.usian.vo;


import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;



public class Rs extends HashMap<String,Object> {
    public Rs(){
        put("code", HttpStatus.SC_OK);
        put("msg","success");
    }
    @Override
    public Rs put(String key, Object value){
        super.put(key,value);
        return this;
    }
    public static Rs ok(){
        return new Rs();
    }
    public static Rs ok(String msg){
        Rs rs =new Rs();
        rs.put("msg",msg);
        return rs;
    }
    public static Rs ok(Map<String,Object> map){
        Rs rs =new Rs();
        rs.putAll(map);
        return rs;
    }

    public static Rs error(int code, String msg){
        Rs rs =new Rs();
        rs.put("code",code);
        rs.put("msg",msg);
        return rs;
    }
    public static Rs error(String msg){
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR,msg);
    }
    public static Rs error(){
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR,"未知异常，请联系管理员");
    }
}
